package Socket;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;

public class SocketSingleton {
	private static Socket arduinoSocket;
	private static Socket n7Socket;
	private static PrintWriter writerA;
	private static PrintWriter writerN;
	private static SocketSingleton instance = null;
	
	public static SocketSingleton getInstance(){
		if(instance == null){
			instance = new SocketSingleton();
		}
		return instance;
	}
	
	private SocketSingleton(){
		try {
			arduinoSocket = new Socket("192.168.5.1", 3000);
			writerA = new PrintWriter(arduinoSocket.getOutputStream());
		}
		catch (IOException e) {
			e.printStackTrace();
		}
		try{
			n7Socket = new Socket("192.168.5.1", 4000);
			writerN = new PrintWriter(n7Socket.getOutputStream());
		}  
		catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public Socket getArduinoSocket(){
		return arduinoSocket;
	}
	
	public Socket getN7Socket(){
		return n7Socket;
	}
	
	public PrintWriter getWriterA(){
		return writerA;
	}
	
	public PrintWriter getWriterN(){
		return writerN;
	}
	
}
